package com.iot.comprehensive.face.dao;

import com.iot.comprehensive.face.model.AccessForm;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author 朱泽玉
 * @Create 2021/6/27 9:48
 * @Description
 * @Modified By:
 */
@Repository
public interface AccessFormDao extends JpaRepository<AccessForm, Integer>, JpaSpecificationExecutor<AccessForm> {
    @Query(value = "select * from access_form where admin_id=?1", nativeQuery = true)
    List<AccessForm> findByAdminId(Long admin_id);

    @Query(value = "select * from access_form where host_id=?1", nativeQuery = true)
    List<AccessForm> findByHostId(Long host_id);

    @Query(value = "select * from access_form where user_id=?1", nativeQuery = true)
    List<AccessForm> findByUserId(Long user_id);

    @Query(value = "select * from access_form where user_id=?1 and state = 1", nativeQuery = true)
    List<AccessForm> findAvailable(Long user_id);
}
